#!/usr/bin/python2.7

import sys;
import re;

regex = re.compile(r"\s+\d\s+(\d+)\s+(\d+)\s+\S+", re.I);

def parseLine(sLine):
    m = regex.search(sLine);
    if m == None:
        return 0;
    else:
        return int(m.group(1));

def matchFile(sFilename, nCode):
    oFile = open(sFilename, "r");
    
    for sLine in oFile:
        nParsedCode = parseLine(sLine);
        if nParsedCode == nCode or nParsedCode == 0:
            if sLine[len(sLine) - 1] == "\n":
                print sLine[:len(sLine) - 1];
            else:
                print sLine;
    
    oFile.close();

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print "Usage:";
        print "    {0} <logfile> <code>".format(__file__);
        exit(1);
    
    sFilename = sys.argv[1];
    nCode = int(sys.argv[2]);
    matchFile(sFilename, nCode);